package com.gree.scmservice.entity.saas;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.gree.common.entity.BaseEntity;
import com.gree.scmservice.entity.saas.vo.SaasCommodityVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Name;
import org.nutz.dao.entity.annotation.Table;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * 包路径: com.gree.scmservice.entity.saas
 * 项目名: scm-api
 * 创建时间: 2021-07-12 11:44
 * 描述: TODO saas 商品表
 **/
@Data
@NoArgsConstructor
@Table("SAAS_COMMODITY")
@ApiModel(description = "saas商品表")
public class SaasCommodity extends BaseEntity {

    /** 商品ID */
    @Name
    @ApiModelProperty("商品ID")
    private String group_id;

    /** 商品类型1:租户2:站点3:服务 */
    @Column
    @ApiModelProperty("商品类型1:租户2:站点3:服务")
    private Integer type;

    /** 商品名称 */
    @Column(hump = true)
    @ApiModelProperty("商品名称")
    private String groupName;

    /** 商品图片 */
    @Column
    @ApiModelProperty("商品图片")
    private String image;

    /** 服务 */
    @Column(hump = true)
    @ApiModelProperty("服务")
    private String addonArray;

    /** 单位 */
    @Column
    @ApiModelProperty("单位")
    private String unit;

    /** 费用 */
    @Column
    @ApiModelProperty("费用")
    private Long fee;

    /** 描述 */
    @Column
    @ApiModelProperty("描述")
    private String dsca;

    /** 状态1:下架2:上架3:试用 */
    @Column
    @ApiModelProperty("状态1:下架2:上架3:试用")
    private Integer status;

    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Column
    @ApiModelProperty("创建时间")
    private LocalDateTime create_time;

    /** 修改时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Column
    @ApiModelProperty("修改时间")
    private LocalDateTime modify_time;

    public void saasCommodityNoPage()
    {
        super.setBaseEntityNull();
    }


    public SaasCommodity(SaasCommodityVo vo) {
        this.group_id = vo.getGroup_id();
        this.type = vo.getType();
        this.groupName = vo.getGroupName();
        this.image = vo.getImage();
        this.addonArray = String.join(",",vo.getAddonArray());
        this.unit = vo.getUnit();
        this.fee = vo.getFee();
        this.dsca = vo.getDsca();
        this.status = vo.getStatus();
        this.create_time =vo.getCreate_time();
        this.modify_time = vo.getModify_time();
    }
}
